import request from '@/utils/request';
import type { BaseBeanModel, ResponsePageData, ResponseBaseData, QueryParamModel } from '@/api/model/baseModel';
import type { downloadParam } from '@/utils/download-util';
import { download } from '@/utils/download-util';
const basePath = '/syslog/syslogconfigs';
/** 日志配置表 */
export interface SysLogConfigDto extends BaseBeanModel {
  /** 服务编码 */
  serviceName?: string;
  /** 类型。DTO:非电子表单,eForm:电子表单 */
  moduleType?: string;
  /** 对应的实体类DTO/存储模型 */
  logConfigClass?: string;
  /** 描述 */
  remark?: string;
  /** 表名称 */
  tableName?: string;
  /** 表描述 */
  tableDes?: string;
  /** 模块名称 */
  logTitle?: string;
  /** 排序号 */
  orderBy?: number;
  /** 关联菜单ID */
  menuId?: string;
  /** 应用ID */
  sysApplicationId?: string;
}

/**
 * 获取分页数据
 * @param param 表格参数
 * @param id 树节点id
 * @returns 表格数据
 */
export function listSysLogConfigByPage(param: QueryParamModel, id: string): Promise<ResponsePageData<SysLogConfigDto>> {
  return request.post(`${basePath}/search-by-page/${id}/v1`, param);
}

/** 获取服务编码 */
export function getServiceNameList() {
  return request.get(`${basePath}/get-service-name-list/v1`);
}
// DTO列表数据
// export function SearchDtoByPagee (param, serviceName) {
//   return request({
//     url: basePath + `/search-dto-by-page/${serviceName}/v1`,
//     params: param,
//     method: 'post'
//   })
// }
/**
 * 获取分页数据
 * @param param 表格参数
 * @param serviceName 编码名称
 * @returns 表格数据
 */
export function SearchDtoByPagee(param: QueryParamModel, serviceName: string) {
  return request.post(`${basePath}/search-dto-by-page/${serviceName}/v1`, param);
}

/**
 * 根据id加载数据
 * @param id 选中行id
 * @returns 表单数据
 */
export function getSysLogConfig(id: string): Promise<ResponseBaseData<SysLogConfigDto>> {
  return request.get(`${basePath}/get/${id}/v1`);
}

/**
 * 保存表单数据
 * @param form 表单数据
 */
export function saveSysLogConfig(form: SysLogConfigDto): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/save/v1`, form);
}

/**
 * 编辑保存表单数据
 * @param form 编辑表单数据
 */
export function editsaveSysLogConfig(form: SysLogConfigDto): Promise<ResponseBaseData<any>> {
  return request.put(`${basePath}/update-sensitive/v1`, form);
}

/**
 * 根据id集合删除数据
 * @param id 选中行id
 */
export function delSysLogConfig(ids: [string]): Promise<ResponseBaseData<any>> {
  return request.delete(`${basePath}/delete-by-ids/v1`, { data: ids });
}

/** 导出xml */
export function exportXml(param: any, name: string) {
  const download1 = {
    url: `${basePath}/export-xml/v1`,
    data: param,
    method: 'post',
    fileName: name
  } as downloadParam;
  return download(download1);
}
